package com.itnan.user.controller;

import com.itnan.user.service.CustomerService;
import com.itnan.user.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by tangjian on 27/4/14.
 */
@Controller
@RequestMapping(value = "/admin")
public class AdminController {

    @Autowired
    private UserService userService;
    @Autowired
    private CustomerService customerService;

    @RequestMapping(value = "/main")
    public String main(Model model) {
        model.addAttribute("totaluser", userService.findAll().size());
        model.addAttribute("totalCustomer", userService.getCustomerSize());
        return "admin/main";
    }

    @RequestMapping(value = "/show")
    public String show(Model model) {
        model.addAttribute("list", userService.findAll());
        return "admin/show";
    }

    @RequestMapping(value = "/search")
    public String search() {
        return "admin/search";
    }

    @RequestMapping(value = "/result")
    public String searchResult(Model model, HttpServletRequest request) {
        String name = request.getParameter("username");

        return "admin/search-result";
    }


    @RequestMapping(value = "/setting")
    public String setting() {
        return "admin/setting";
    }

}
